<?php
class Student_model extends MY_Model {
	public function __construct(){
		parent::__construct();	
		$this->setTableName('u_c_student');
	}
	
	public function login($username,$password){
		$r = $this->select('classid,name,password','name="'.$username.'" AND password="'.$password.'"','classid desc',1);
		return $r[0];
	}
	
	public function info($sid){
		$r = $this->select('*','classid='.$sid);
		return $r[0];
	}
	
	public function save($classid,$password){
		$r = $this->update(['password'=>$password],['classid'=>$classid]);
		return $r;
	}
	
	public function teacherList($sid){
		$sql = "SELECT s_t.id,s_t.tid,t.name,s_t.lesson FROM wq_u_m_s_t as s_t,wq_u_c_teacher as t WHERE t.classid=s_t.tid AND s_t.score=0 AND s_t.sid={$sid}";
		$r = $this->db->query($sql)->result_array();
		return $r;
	}
}
?>